<script setup lang="ts">
import Versions from './components/Versions.vue'

const ipcHandle = () => window.api.HelloWorld(`'I'm ele-app 123`)

window.addEventListener('contextmenu', (e: any) => {
    e.preventDefault()
    window.electron.ipcRenderer.send('show-context-menu')
})

window.electron.ipcRenderer.on('menu-command', (_, command: string) => {
    console.log(command)
})

const openWebUrl = () => {
    window.open('https://electron-vite.org/')
}
</script>

<template>
    <img alt="logo" class="logo" src="./assets/electron.svg" />
    <div class="creator">Powered by electron-vite</div>
    <div class="text">
        Build an Electron app with
        <span class="vue">Vue</span>
        and
        <span class="ts">TypeScript</span>
    </div>
    <p class="tip">Please try pressing <code>F12</code> to open the devTool</p>
    <div class="actions">
        <div class="action">
            <el-button @click="openWebUrl">Documentation</el-button>
            <!-- <a href="https://electron-vite.org/" target="_blank" rel="noreferrer">Documentation</a> -->
        </div>
        <div class="action">
            <el-button type="primary" @click="ipcHandle">Send IPC</el-button>
            <!-- <a target="_blank" rel="noreferrer" @click="ipcHandle">Send IPC</a> -->
        </div>
    </div>
    <Versions />
</template>
